package com.core.common.manger.notify;

import cn.hutool.http.HttpUtil;
import com.core.common.cons.MsgProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @program: maobao-parent
 * @description:
 * @author: honglei
 * @create: 2022-05-06 10:49
 */
@Slf4j
//@Service
public class MsgServiceImpl implements IMsgService {

    @Resource
    MsgProperties msgProperties;

    @Override
    public void  sendMsg(String json){
        if (Objects.isNull(msgProperties)){
            return;
        }
        if (msgProperties.getEnable()==1 && StringUtils.hasText(msgProperties.getUrl())){
            String result = HttpUtil.createPost(msgProperties.getUrl()).body(json).execute().body();
            System.out.println(result);
        }
    }

}
